package com.collins.thread.practices.redPocket;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class Sender {
    // create one lock
    public static final Object lock = new Object();
    // total money
    public static final BigDecimal ttl_money = new BigDecimal(1000);
    public static BigDecimal money = new BigDecimal(1000);
    // total receiver
    public static final int ttl_people = 10;
    public static int people = 10;
    // minimum money quota
    public static final BigDecimal MINIMUM_MONEY = new BigDecimal("0.01");
    public static final BigDecimal TTL_AVERAGE_MONEY =
            new BigDecimal(ttl_money.doubleValue()/ttl_people).setScale(2, RoundingMode.HALF_UP);
    // rng
    public static final Random rand = new Random();

    public static void main(String[] args) {
        Receiver receiverRunnable = new Receiver();
        Map<String, Thread> threads = new HashMap<>();
        for (int i = 0; i < people; i++) {
            String name = "receiver-" + (i+1);
            Thread t = new Thread(receiverRunnable);
            t.setName(name);
            threads.put(name, t);
            t.start();
        }
    }
}
